package com.cy.pj.sys.service.impl;

import com.cy.pj.sys.dao.SysNoticeDao;
import com.cy.pj.sys.pojo.SysNotice;
import com.cy.pj.sys.service.SysNoticeService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Slf4j
@Service
public class SysNoticeServiceImpl implements SysNoticeService {
    //初始化日志对象(org.slf4j.*)门面模式
   //7 private  static final Logger log = LoggerFactory.getLogger(SysNoticeServiceImpl.class);
    @Autowired
    private SysNoticeDao sysNoticeDao;
    public SysNoticeServiceImpl(SysNoticeDao sysNoticeDao){
        this.sysNoticeDao =sysNoticeDao;
    }

    public int saveNotice(SysNotice notice) {
        int rows = sysNoticeDao.insertNotice(notice);
        return rows;
    }

    @Override
    public List<SysNotice> findNotices(SysNotice notice) {
        Long start = System.currentTimeMillis();
        log.info("method start {} ",start);
        List<SysNotice>list = sysNoticeDao.selectNotice(notice);
        Long end = System.currentTimeMillis();
        System.out.println(end-start);
        log.info("method end {} ",end);
        return list;

    }

    @Override
    public int deleteById(Long... id) {
        int rows= sysNoticeDao.deleteById(id);
        return rows;
    }

    @Override
    public SysNotice findById(Long id) {
        SysNotice notice=sysNoticeDao.selectById(id);
        return notice;
    }

    @Override
    public int updateNotice(SysNotice notice) {
        int rows=sysNoticeDao.updateNotice(notice);
        return rows;
    }

}
